import React from 'react'
import {Route} from 'react-router-dom';
import RouterInterface  from './routerInterface';
import {mainRouter} from './mainRouter';
import {globalRouter} from './globalRouter';

export function renderRouter(config:RouterInterface[],props?:any){
  return config.map( (item,index) =>{
    let {path,component:Component,routes} = item;
    return(
      <Route 
        key={path}
        path={path} 
        component={ props => {
          return(<React.Suspense fallback="正在加载中....">
                  <Component {...props} routes={routes}></Component>
              </React.Suspense>)
          }}
        />
      );
  });
  
}



export default renderRouter(mainRouter.concat(globalRouter));



